import request from '@/utils/request';
import type { BindMobileLoginParams, BindMobileLoginResponse, CodeLoginParams, CodeLoginResponse, PasswordLoginParams, PasswordLoginResponse, QQLoginParams, QQLoginResponse, RegisterParams, SendCodeParams } from '@/type/LoginType';
import type { ResponseType } from '@/type/ResponseType';

enum Enum {
  passwordLoginAPI = '/login/password',
  codeLoginAPI = '/login',
  sendCodeAPI = '/code',
  registerAPI = '/register',
  logoutAPI = '/logout',
  qqLoginAPI = '/login/thirdparty',
  bindMobileLoginAPI = '/login/binding',
  cancelBindMobileAPI = '/unbound'
}

/**
 * @description 密码登录的接口
 * */
export const passwordLoginAPI = (data: PasswordLoginParams) => request.post<PasswordLoginResponse, ResponseType<PasswordLoginResponse>>(Enum.passwordLoginAPI, data);


/**
 * @description 验证码登录的接口
 * */
export const codeLoginAPI = (data: CodeLoginParams) => request.post<CodeLoginResponse, ResponseType<CodeLoginResponse>>(Enum.codeLoginAPI, data);


/**
 * @description 获取手机验证码的接口
 * */
export const sendCodeAPI = (params: SendCodeParams) => request.get<{ code: string }, ResponseType<{ code: string }>>(Enum.sendCodeAPI, { params });

/**
 * @description 注册的接口
 * */
export const registerAPI = (data: RegisterParams) => request.post<{ id: string }, ResponseType<{ id: string }>>(Enum.registerAPI, data);

/**
 *@description qq登录的接口
 * */
export const qqLoginAPI = (data: QQLoginParams) => request.post<QQLoginResponse, ResponseType<QQLoginResponse>>(Enum.qqLoginAPI, data);

/**
 * qq登录失败后绑定手机号进行登录的接口
 * */
export const bindMobileLoginAPI = (data: BindMobileLoginParams) => request.post<BindMobileLoginResponse, ResponseType<BindMobileLoginResponse>>(Enum.bindMobileLoginAPI, data);

/**
 * 三方登录-解除绑定的接口
 * */
export const cancelBindMobileAPI = (params: string) => request.put<null, ResponseType<null>>(`${Enum.cancelBindMobileAPI}/${params}`);
/**
 * @description 退出登录的接口
 * */
export const logoutAPI = () => request.get<null, ResponseType<null>>(Enum.logoutAPI);